
var Type = getUrlParam('type');
(function(){
    // var rate='';
    // if(Type=="parcels"){
    //     rate= $.cookie("ParcelRate") || 1;
    // }else if(Type == "rings"){
    //     rate= $.cookie("RingRate") || 1;
    // }else if(Type== "gems"){
    //     rate= $.cookie("GemRate") || 1;
    // }else if(Type == "emeralds"){
    //     rate= $.cookie("EmeraldRate") || 1;
    // }else if(Type== "golds"){
    //     rate= $.cookie("PrimeGoldRate") || 1 ;
    // }

    //现货换算
    //采购价格美金和人民币的转换
    $("#purchaseUSDPerGrain").bind('input propertychange', function() {
        var usdVal=$(this).val();
        var purchaseRate=$("#purchaseExchange").val();
        $("#purchaseRMB").val(formatRMBPrice(usdVal*purchaseRate));
    })

    $("#purchaseRMB").bind('input propertychange', function() {
        var rmbVal=$(this).val();
        var purchaseRate=$("#purchaseExchange").val();
        $("#purchaseUSDPerGrain").val(formatUSDPrice(rmbVal/purchaseRate));
    })
    //通过采购汇率计算
    $("#purchaseExchange").bind('input propertychange',function(){
        var purchaseRate=$(this).val();
        var usdVal=$("#purchaseUSDPerGrain").val();
        if(usdVal && purchaseRate){
            $("#purchaseRMB").val(formatRMBPrice(usdVal*purchaseRate));
        }
        var rmbVal=$("#purchaseRMB").val();
        if(rmbVal && purchaseRate){
            $("#purchaseUSDPerGrain").val(formatUSDPrice(rmbVal/purchaseRate));
        }
    })


        //产品订单换算
        $("#_confirmPrice").bind('input propertychange',function(){
            var val=Number($(this).val());
            var rate=Number($("#_salesRate").val());
            var usd_p=formatUSDPrice(val/rate);
            $("#_BEFPrice").val(usd_p);
        });
        $("#_BEFPrice").bind('input propertychange',function(){
            var val=Number($(this).val());
            var rate=Number($("#_salesRate").val());
            var usd_r=formatUSDPrice(val*rate);
            $("#_confirmPrice").val(usd_r);
        });
        $("#_salesRate").bind('input propertychange',function(){
            var rate=Number($(this).val());
            var val=Number($("#_confirmPrice").val());
            var usd_p=formatUSDPrice(val/rate);
            $("#_BEFPrice").val(usd_p);
        });




})();